package com.zhiyou.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhiyou.model.FyTeacher;
import com.zhiyou.service.TeacherService;
import com.zhiyou.utils.JsonResult;

@RestController
@RequestMapping("teacher/")
public class TeacherController {

	@Autowired
	TeacherService teacherService;
	@GetMapping(value="list")
	public JsonResult show(HttpServletRequest request,HttpServletResponse response){
	
		return new JsonResult(teacherService.select(),"查询成功");
		
	}
	@GetMapping("add")
	public JsonResult add(FyTeacher fyTeacher,HttpServletRequest request, HttpServletResponse response){
		teacherService.add(fyTeacher);
		return new JsonResult("添加成功");
		
	} 
	@DeleteMapping("delete")
	public JsonResult delete(int id ,HttpServletRequest request, HttpServletResponse response){
		teacherService.delete(id);
		return new JsonResult("删除成功");
		
	} 
	@PutMapping("update")
	public JsonResult update(FyTeacher fyTeacher,HttpServletRequest request, HttpServletResponse response){
		teacherService.update(fyTeacher);
		return new JsonResult("修改成功");
		
	} 
	
}
